﻿<%@ WebHandler Language="C#" Class="LoginHandler" %>

using System;
using System.Web;

public class LoginHandler : IHttpHandler {

    public void ProcessRequest(HttpContext context)
    {
        //if (!HttpContext.Current.User.Identity.IsAuthenticated)
        //{
        string loginUrl;
        string returnUrl = context.Request.Params["returnUrl"];

        if (returnUrl.Contains("/System/"))
        {
            loginUrl = "System/Login.aspx";
        }
        else
        {
            loginUrl = "ForeProgram/Login.aspx";
        }

        if (!string.IsNullOrEmpty(context.Request.Params["returnUrl"]))
        {
            loginUrl = loginUrl + "?returnUrl=" + HttpUtility.UrlEncode(context.Request.Params["returnUrl"]);
        }
        context.Response.Redirect(loginUrl);
        //}
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}